package org.example.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import org.example.domain.TJrProduct;
import org.example.service.TJrProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("product")
public class ProdoctController {
    @Autowired
    TJrProductService productService;


    /**
     *
     * @Description: 加载租房分期列表
     * @return ModelAndView
     */
    @GetMapping("/productInstallment")
    public AjaxResult productInstallmentList(){
        List<TJrProduct> list = productService.getProductInstallment(1);
        return AjaxResult.success(list);
    }



    /**
     *
     * @Description: 加载收房贷列表
     * @return ModelAndView
     */
    @GetMapping("/productRecieve")
    public AjaxResult productRecieveList() {
        List<TJrProduct> list = productService.getProductInstallment(2);
        return AjaxResult.success(list);
    }

    /**
     *
     * @Description: 加载租约保理列表
     * @return ModelAndView
     */
    @GetMapping("/productProtect")
    public AjaxResult productProtectList() {
        List<TJrProduct> list = productService.getProductInstallment(3);
        return AjaxResult.success(list);
    }


    /**
     *
     * @Description: 保存或修改租房分期,收房贷,租约保理产品
     * @return R
     */
    @PostMapping("/saveOrUpdateJrProduct")
    public AjaxResult saveJrProduct(@RequestBody TJrProduct tJrProduct) {
     AjaxResult ajaxResult = productService.saveOrUpdates(tJrProduct);
    return ajaxResult;
    }
    /**
    * 进行删除操作
    * 软删除，进行修改操作
    */
    @DeleteMapping("/softRemove")
    public AjaxResult softRemove(Integer id){
        AjaxResult ajaxResult = productService.softRemove(id);
        return ajaxResult;
    }





}
